#include "comm.hpp"

int main()
{
  //创建key
  key_t key = GetKey();

  //获取shmid
  int shmid = Getshm(key,gsize);
  
  toHex(key);

  //关联
  char* Start = AttachShm(shmid);
  printf("%p\n", Start);
  //通信
  int i = 0;
  while(i < 26)
  {
    char character = 'A' + i;
    Start[i] = character;
    ++i;
    Start[i] = '\0';
    cout << "I am client, I sent message : " << Start << " to server." << endl;
    sleep(1);
  }
  
  //while(1)
  //{
  //  scanf("%s\n",Start);
  //}

  //去关联
  DetachAttach(Start);

  return 0;
}
